package com.ocom.accesservice.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.accesservice.dao.IDaoMjQrList;
import com.ocom.accesservice.service.MjQrListService;
import com.ocom.common.entity.master.EntityMjQrList;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.enums.MasterSlaveEnum;
import com.ocom.mysql.aspect.DataSourceAspect;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;


@Service
public class MjQrListServiceImpl extends ServiceImpl<IDaoMjQrList, EntityMjQrList> implements MjQrListService {

    @DataSourceAspect(type= DataSourceEnum.MAIN_DB,isMaster = MasterSlaveEnum.MASTER)
    @Transactional
    @Override
    public EntityMjQrList saveOne(EntityMjQrList entityMjQrList) {
        this.save(entityMjQrList);
        return entityMjQrList;
    }

    @DataSourceAspect(type= DataSourceEnum.MAIN_DB,isMaster = MasterSlaveEnum.SLAVE)
    @Override
    public EntityMjQrList searchQrCode(String Qecode) {
        QueryWrapper<EntityMjQrList> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("qr_code",Qecode);
        queryWrapper.last("limit 1");
        return this.getOne(queryWrapper);
    }
}
